package controller;

import java.net.URI;
import java.net.URISyntaxException;

import restaurant.Location;

public class LocationUrlBuilder {
    public static String getHrefLink(final Location location) throws URISyntaxException {
        final StringBuilder address = new StringBuilder();
        address.append(location.getAddress());
        address.append(", ");
        address.append(location.getCity());
        address.append(", ");
        address.append(location.getState());

        final StringBuilder query = new StringBuilder();
        query.append("q=");
        query.append(address.toString());

        query.append("&");

        query.append("f=");
        query.append("d");

        return new URI("http", "maps.google.com", "/maps", query.toString(), null).toASCIIString();
    }

    public static String getSrcLink(final Location location) throws URISyntaxException {
        final StringBuilder address = new StringBuilder();
        address.append(location.getAddress());
        address.append(",");
        address.append(location.getCity());
        address.append(",");
        address.append(location.getState());

        final StringBuilder query = new StringBuilder();
        query.append("center=");
        query.append(address.toString());

        query.append("&");

        query.append("markers=");
        query.append("color:purple");
        query.append("|");
        query.append(address.toString());

        query.append("&");

        query.append("zoom=");
        query.append(14);

        query.append("&");

        query.append("size=");
        query.append(128);
        query.append("x");
        query.append(128);

        query.append("&");

        query.append("maptype=");
        query.append("roadmap");

        query.append("&");

        query.append("sensor=");
        query.append(false);

        return new URI("http", "maps.googleapis.com", "/maps/api/staticmap", query.toString(), null).toASCIIString();
    }
}
